package com.shop.cereshop.commons.tencent.im.enums.notice;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * @description: 系统消息类型枚举
 * @author zdd
 * @date 2025/10/10 11:27
 * @version 1.0
 */
public enum SysMsgTypeEnum {
    //消息大类 1-系统消息 2-互动消息 3-点赞和收藏
    SYSTEM_MSG(1, "系统消息 "),
    INTERACTIVE_MSG(2, "互动消息"),
    LIKE_AND_COLLECT(3, "点赞和收藏"),
    ;

    private final Integer code;
    private final String msg;

    private static final Map<Integer, SysMsgTypeEnum> CODE_MAP = new HashMap<>();

    static {
        for (SysMsgTypeEnum type : SysMsgTypeEnum.values()) {
            CODE_MAP.put(type.getCode(), type);
        }
    }

    SysMsgTypeEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return this.code;
    }

    public String getMsg() {
        return this.msg;
    }

    public static String getMsgByCode(Integer code) {
        if (Objects.isNull(code)) {
            return "";
        }
        SysMsgTypeEnum type = CODE_MAP.get(code);
        return type != null ? type.getMsg() : "";
    }
}
